package com.yungee.config.listener;

import lombok.extern.slf4j.Slf4j;
import org.apache.commons.fileupload.ProgressListener;

/**
 * @author wangyun
 * @date 2021/11/11 13:01
 */
@Slf4j
public class ServerFileUploadListener implements ProgressListener {

    private int percent = 0;

    @Override
    public void update(long pBytesRead, long pContentLength, int pItems) {
        int process = Math.round(new Float(pBytesRead) / new Float(pContentLength) * 100);
        if (process > percent) {
            log.info("上传进度>pre:{},after:{}", percent, process);
            percent = process;
        }
    }
}
